<?php
/*
 * @Descripttion: 
 * @version: 
 * @Author: ewgof
 * @Date: 2020-08-11 15:04:13
 * @LastEditors: ewgof
 * @LastEditTime: 2020-09-05 12:43:41
 */
namespace cw;

use cw\File;

class Lang
{
    protected $lang = [];

    public function __construct()
    {
        global $lang;

        $this->lang = &$lang;

        if (!$this->lang) {
            $this->lang = require_once \__LANG__ . config('app.lang') . '.php';
        }
    }


    public function get(String $name) : String
    {
        if (empty($name) && $name != 0) {
            return '';
        }
        return $this->lang[$name];
    }


    public function set(String $name, String $val) : boolean
    {
        if (empty($name) || empty($val)) {
            return false;
        }

        $this->lang[$name] = $val;
        return true;
    }
}
